﻿// See https://aka.ms/new-console-template for more information
using System.Collections;
//1.逆序输出：9  2 5 7 8  --> 8 7 5 2 9
 int[] arr1 = {9,2,5,7,8};
 getFan(arr1);
 static void getFan(int[] arr){
     for (int i = 0; i < arr.Length; i++)
     {
         Console.WriteLine(arr[arr.Length-i-1]);
     }
 }
 
//2. 求最大最小值{1, -1, 5, 6, 8, 101}
int[] arr2 = {1, -1, 5, 6, 8, 101};
getMaxMin(arr2);
static void getMaxMin(int[] arr){
    int MaxNum = arr[0],MinNum = arr[0];
    for (int i = 0; i < arr.Length; i++)
    {
        MaxNum = arr[i]>MaxNum ? arr[i] : MaxNum;
        MinNum = arr[i]<MinNum ? arr[i] : MinNum;
    }
    Console.WriteLine($"最大值:{MaxNum},最小值:{MinNum}");
}

//3. a=9 b=5 c=6  --> 5 6 9
int a = 9,b = 5,c = 6;
getShun(a,b,c);
static void getShun(int a,int b,int c){
    int[] arr = {a,b,c};
    var temp = 0;
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if (arr[j+1] < arr[j])
            {
                temp = arr[j+1];
                arr[j+1] = arr[j];
                arr[j] = temp;
            }
        }
    }
    foreach (var item in arr)
    {
        Console.WriteLine(item);
    }
}